import subprocess

def run_target_script(params):
    """调用外部Python文件的函数, 实时输出内容"""
    
    cmd = ["python", "SfcdSagin_main.py"] + params
    try:
        subprocess.run(cmd)
        
    except Exception as e:
        return f"仿真失败: 发生错误 - {str(e)}"

def main():
    num_repeats = 10
    train_batch_param_1 = [["SolverDeployDRLSFCP"] for _ in range(num_repeats)]
    train_batch_param_2 = [["SolverDeployPPOSFC"] for _ in range(num_repeats)]
    train_batch_param_3 = [["SolverDeployGatDrlV1"] for _ in range(num_repeats)]
    group_batch_param_1 = [["SolverDeployLMSFCP", "SolverDeployTMSM", "SolverDeployPGRA"]]
    group_batch_param_2 = [["SolverDeploySharedRandom"], ["SolverDeploySharedGreedy"], ["SolverDeploySharedPso"]]
    total_batch_param = train_batch_param_1 + train_batch_param_2 + group_batch_param_1 + group_batch_param_2
    
    for idx, params in enumerate(train_batch_param_3, 1):
        print("#"*20 + f"正在执行第{idx}次，参数={params}" + "#"*20)
        result = run_target_script(params)
        print(result)
        print()

if __name__ == "__main__":
    main()